package org.boge.sharpdoc.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.boge.sharpdoc.dao.BannerDao;
import org.boge.sharpdoc.bean.Banner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BannerService {
    @Autowired
    private BannerDao bannerDao;

    public Integer addItem(Integer docid, String picurl, Integer adminid) {
        return bannerDao.addItem(docid, picurl, adminid);
    }

    public List<Banner> findUseful() {
        return bannerDao.findUseful();
    }

    public Integer updateStatus(Integer bannerid, String status) {
        return bannerDao.updateStatus(bannerid, status);
    }

    public PageInfo<Banner> findAllWithPage(Integer index, Integer pageSize) {
        return PageHelper.startPage(index, pageSize, "bannerid desc").doSelectPageInfo(() -> bannerDao.findAll());
    }
}